! pip install cesiumpy
import cesiumpy
v = cesiumpy.Viewer()
#geojsonを読み込み座標棟を取得
res = cesiumpy.io.read_geojson('./geojson/prefectures/10.json')
#グラフの値をextrudedHeightとすることで値に応じてポリゴンを浮き出させる
myExtrudedHeight = 10e3
#エンティティーへ設定
v.entities.add(res, extrudedHeight=myExtrudedHeight)
#描写
v
#ウィジェットの有無は辞書型で渡すので注意
options = dict(\
animation=False,\
timeline=False,\
fullscreenButton=False,\
)
v = cesiumpy.Viewer(**options)
res = cesiumpy.io.read_geojson('./geojson/prefectures/10.json')
myExtrudedHeight = 10e3
#各種プロパティの設定
myName = '群馬県'
myDescription = 'I love Gunma'
myMaterial = cesiumpy.color.Color.fromCssColorString('pink').withAlpha(0.8)
myOutlineColor = cesiumpy.color.Color.fromCssColorString('#FF0000')
v.entities.add(\
res,\
name = myName,\
#おそらくdescriptionは非対応
description=myDescription,\
extrudedHeight = myExtrudedHeight,\
material = myMaterial,\
outline =True,\
outlineColor = myOutlineColor,\
)
v
import json
import os
import random
with open('./myList.json') as f:
ml = json.load(f)
f.close()
def setDir(code):
n = int(code)
if (n > 1000):
return code[0:2]
else:
return "mergedPrefectures"
def setEntitiy(code,val,rgb1,rgb2):
path = './geojson/'+setDir(code)+'/'+code+'.json'
res = cesiumpy.io.read_geojson(path)
myName = ml[code]
myMaterial = cesiumpy.color.Color.fromCssColorString(rgb1)
myOutlineColor = cesiumpy.color.Color.fromCssColorString(rgb2)
v.entities.add(res,\
name=myName,\
extrudedHeight=val,\
material=myMaterial,\
outline=True,\
outlineColor=myOutlineColor)
def setRandomEntities(code):
list = []
path = 'geojson/'+code
for file in os.listdir(path):
base, ext = os.path.splitext(file)
if ext == '.json':
list.append(base)
list.sort()
for i in list:
val = random.randrange(10e3)
clr = '#C'+str(val).zfill(5)
setEntitiy(i,val,clr,clr)
v = cesiumpy.Viewer(**options)
#今回はランダムな値をsetEntitiy()に代入
setRandomEntities('10')
v






v = cesiumpy.Viewer(**options)
for i in range(1,48):
val = random.randrange(10e4)
clr = '#E'+str(val).zfill(5)
setEntitiy(str(i).zfill(2),val,clr,clr)
v